package com.yaowk.web.mall.clothing.controller;

import com.yaowk.api.mall.clothing.model.GoodsClass;
import com.yaowk.api.mall.clothing.service.IGoodsClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "商品分类控制器")
@RequestMapping("/mall/clothing/goodsClass")
public class GoodsClassController {

    @Autowired
    private IGoodsClassService goodsClassService;


    @GetMapping
    @ApiOperation("商品分类列表")
    public List<GoodsClass> list() {
        List<GoodsClass> goodsClasses = goodsClassService.findAll();
        return goodsClasses;
    }

    @PostMapping
    @ApiOperation("保存商品分类")
    public GoodsClass save(GoodsClass goodsClass) {
        goodsClass = goodsClassService.save(goodsClass);
        return goodsClass;
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除商品分类")
    public void delete(@PathVariable Integer id) {
        goodsClassService.deleteById(id);
    }

    @PutMapping("/show/{id}")
    @ApiOperation("显示分类")
    public void show(@PathVariable Integer id) {
        goodsClassService.show(id);
    }

    @PutMapping("/hadden/{id}")
    @ApiOperation("隐藏分类")
    public void hidden(@PathVariable Integer id) {
        goodsClassService.hidden(id);
    }

}
